package com.hopu.oa.service.impl.plan;

import com.hopu.oa.dao.plan.AoaAttachmentListDao;
import com.hopu.oa.dao.plan.AoaPlanListDao;
import com.hopu.oa.entity.plan.AoaPlanList;
import com.hopu.oa.entity.process.AoaAttachmentList;
import com.hopu.oa.service.plan.AoaPlanListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AoaPlanListImpl implements AoaPlanListService {

    @Autowired
    private AoaPlanListDao aoaPlanListDao;

    @Autowired
    private AoaAttachmentListDao aoaAttachmentListDao;


    //    文件修改
    @Override
    public void insertUpdate(AoaAttachmentList aoaAttachmentList, AoaPlanList aoaPlanList) {
        if (aoaAttachmentList.getAttachmentPath() == null) {
            System.out.println("路径为空！");
        } else {
            aoaAttachmentListDao.insert(aoaAttachmentList);
            aoaPlanList.setAttachId(aoaAttachmentList.getAttachmentId());
        }
        aoaPlanListDao.updateById(aoaPlanList);
    }

    //    文件上传
    @Override
    public void insert(AoaAttachmentList aoaAttachmentList, AoaPlanList aoaPlanList) {
        if (aoaAttachmentList.getAttachmentPath() == null) {
            System.out.println("路径为空！");
        } else {
            aoaAttachmentListDao.insert(aoaAttachmentList);
            aoaPlanList.setAttachId(aoaAttachmentList.getAttachmentId());
        }
        aoaPlanListDao.insert(aoaPlanList);
    }

    //    模糊分页排序
    @Override
    public List<AoaPlanList> selectAll(Integer userId, String baseKey, Integer index, Integer size, Integer type, Integer status, Integer time) {
        return aoaPlanListDao.selectAll(userId, baseKey, index, size, type, status, time);
    }
}
